﻿using NLog;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.Entity.Infrastructure.Interception;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    public class MyDbInterceptor : IDbCommandInterceptor
    {

        private Logger logger = LogManager.GetCurrentClassLogger();


        #region IDbCommandInterceptor
        public void NonQueryExecuted(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
        {
            logger.Info($"NonQueryExecuted -- {command.CommandText}");
        }

        public void NonQueryExecuting(DbCommand command, DbCommandInterceptionContext<int> interceptionContext)
        {
            //
            logger.Info($"NonQueryExecuted -- {command.CommandText}");
        }

        public void ReaderExecuted(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
        {
            //
            logger.Info($"ReaderExecuted -- {command.CommandText}");
        }

        public void ReaderExecuting(DbCommand command, DbCommandInterceptionContext<DbDataReader> interceptionContext)
        {
            logger.Info($"ReaderExecuted -- {command.CommandText}");
        }

        public void ScalarExecuted(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
        {
            logger.Info($"ScalarExecuted -- {command.CommandText}");
        }

        public void ScalarExecuting(DbCommand command, DbCommandInterceptionContext<object> interceptionContext)
        {
            logger.Info($"ScalarExecuting -- {command.CommandText}");
        }

        #endregion IDbCommandInterceptor
    }
}
